CC 	= gcc
INSTALL	= install
IFLAGS  = -I/usr/local/include -I../../csf/include -I../../csf/confparser -I../../utils/include -I../../csf/monitor
CFLAGS	= $(cflags) 
PREDEF = $(pdef)
LDFLAGS = -shared -L../../lib -lprotocol -L/usr/local/lib/ -lconfparser -lcurl -lmonitor

LINK	= -Wl
OBJS	= mc.o
DIRS	= ./http_request
WARN    = $(warn)

VARLIST	= cflags="$(CFLAGS)" pdef="$(PREDEF)" warn="$(WARN)"

.PHONY: clean

.c.o:
	@(echo "start to compile"); 
	$(CC) $(WARN) -c $*.c $(CFLAGS) $(IFLAGS) $(PREDEF)

mc.so: $(OBJS)
	$(CC) $(IFLAGS) -o $@ $(DEBUG) $(OBJS) $(LINK) $(LDFLAGS)
	mv -f $@ ../../bin/; \
        set -e; for i in $(DIRS); do \
         (set -e; echo "[$$i]"; cd $$i; \
         $(MAKE) -f freebsd.mk $(VARLIST)) || exit 1; \
        done;
clean:
	@(echo "clean mc ")
	rm -f $(OBJS) \
        set -e; for i in $(DIRS); do \
         (set -e; echo "[$$i]"; cd $$i; \
         $(MAKE) -f freebsd.mk clean) || exit 1; \
        done;
	rm -f *.o ../../bin/mc.so


